﻿#include "DeviceDemoVoltage.h"
#include "../PublicService/SettingData.h"

using namespace DeviceLayer;

DYNAMIC_CREATE(DeviceDemoVoltage)

DeviceDemoVoltage::DeviceDemoVoltage()
{
}

bool DeviceDemoVoltage::InitFromSettingData(const QString &path)
{
    //必须要调用父类的InitFromSettingData
    bool result = Device::InitFromSettingData(path);
    if (result)
    {
        minVoltage = GET_SETTING_FLOAT(path + "/MinVoltage");
        maxVoltage = GET_SETTING_FLOAT(path + "/MaxVoltage");
        voltage = GET_SETTING_FLOAT(path + "/DefaultVoltage");
        return true;
    }
    else
        return false;

}

bool DeviceDemoVoltage::QueryData()
{
    PutDataToPool("voltage", GetVoltage());  //同时将电压值放到数据池里。
    PutDataToPool("warning", warning);       //也将是否有警告放到数据池里。
    PutDataToPool("switchedOn", switchedOn); //也将当前开关状态放数据池里。

    return true;
}
